home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / DELPHI32 / GRAPHICS / TS32 / TS32.ZIP / Dib.int < prev    next >
Text File  |  1996-03-21  |  3KB  |  102 lines

  1. unit Dib;
  2.  
  3.  
  4. (*********************************************
  5. TDIB->TComponent
  6.  
  7. A non-visual encapsulation of a Windows DIB.  The
  8. DIB data is stored in binary format in the form's
  9. DFM file.
  10.  
  11. Properties
  12.  
  13. DataLoaded-
  14.   Indicates whether or not DIB data is loaded into the TDIB.
  15.   You can set this to FALSE to clear DIB data.
  16. DIBCanvas-
  17.   An instance of a TDIBCanvas that is owned by this TDIB.  Use
  18.   this TDIBCanvas to access or modify the DIB data.  You can
  19.   also obtain the dimensions of the DIB from the TDIBCanvas.
  20. DIBLoadFile-
  21.   Setting this property to a valid BMP file will cause the DIB
  22.   data from that file to load into the TDIB.  The file name
  23.   reference is not retained, but the physical DIB data is.
  24. DIBLoadImage-
  25.   Setting this property to a TImage control on the form will
  26.   cause the DIB data from that TImage to load into the TDIB.  The
  27.   TImage reference is not retained, but the physical DIB data is.
  28. FramesX,FramesY-
  29.   Indicates whether the DIB data is partitioned into segments.
  30.   Provide the number of frames along the X and Y axis.  TDIBSprite
  31.   uses this information when rendering sprites.
  32. NumColors-
  33.   The number of colors used by the DIB.  Currently only 256 color
  34.   DIBs are supported.
  35. Size-
  36.   The total size of the DIB data in bytes.
  37.  
  38. Events
  39.  
  40. Methods
  41. *********************************************)
  42.  
  43. interface
  44.  
  45. uses
  46.   SysUtils, Graphics, Windows, Messages, Classes, Controls, Grafix,
  47.   Forms, DsgnIntf, MemoryMappedFile, ExtCtrls, DIBCanvas, Dialogs;
  48.  
  49. type
  50.  
  51.   EDIB = class( Exception );
  52.  
  53.   TDIB = class( TComponent )
  54.   private
  55.      nDummy: word;
  56.      niDummy: integer;
  57.      nDummyLong: longint;
  58.      pDIBBits: pointer;
  59.      FDIBCanvas: TDIBCanvas;
  60.      FFileName: TFileName;
  61.      FSize: integer;
  62.      FFramesX, FFramesY: integer;
  63.      FNumColors: word;
  64.      FImage: TImage;
  65.      procedure CleanUp;
  66.      procedure LoadBitmapFile( const s: TFileName );
  67.      procedure ReadImage( Stream: TStream );
  68.      procedure WriteImage( Stream: TStream );
  69.   protected
  70.      procedure DefineProperties( Filer: TFiler ); override;
  71.      procedure SetFileName( const sName: TFileName );
  72.      procedure SetImage( im: TImage );
  73.      procedure SetDIBCanvas( dc: TDIBCanvas );
  74.      procedure LoadFromBitmap( bm: Graphics.TBitmap );
  75.      procedure LoadFromFile( const sName: TFileName );
  76.      function GetDataLoaded: boolean;
  77.      procedure SetDataLoaded( b: boolean );
  78.   public
  79.      constructor Create( AOwner: TComponent ); override;
  80.      destructor Destroy; override;
  81.   published
  82.      property DataLoaded: boolean read GetDataLoaded write SetDataLoaded;
  83.      property DIBCanvas: TDIBCanvas read FDIBCanvas write SetDIBCanvas;
  84.      property DIBLoadFile: TFileName read FFileName write SetFileName;
  85.      property FramesX: integer read FFramesX write FFramesX;
  86.      property FramesY: integer read FFramesY write FFramesY;
  87.      property DIBLoadImage: TImage read FImage write SetImage;
  88.      property NumColors: word read FNumColors write nDummy;
  89.      property Size: integer read FSize write niDummy;
  90.   end;
  91.  
  92.   TDIBFileNameProperty = class( TPropertyEditor )
  93.   private
  94.   protected
  95.   public
  96.      procedure Edit; override;
  97.      function GetAttributes: TPropertyAttributes; override;
  98.      function GetValue: string; override;
  99.      procedure SetValue( const Value: string ); override;
  100.   end;
  101.  
  102. procedure Register;